package com.sefonsoft.dataanalysis.service.impl.stjj.mhwz;

import java.util.Map;

import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

import com.sefonsoft.dataanalysis.model.stjj.mhwz.StjjMhwzBmfwBean;
import com.sefonsoft.dataanalysis.service.impl.BaseService;
import com.sefonsoft.dataanalysis.service.model.Datas;
import com.sefonsoft.dataanalysis.utils.Tools;

/**
 * 部门服务Service
 */
@Service
public class StjjMhwzBmfwBeanService extends BaseService<StjjMhwzBmfwBean> {

	@Override
	public Datas<StjjMhwzBmfwBean> dataAnalysisByHtml(Document doc) {
		Elements  el = doc.select("ul[class='fn-clear'] li div");
		Datas<StjjMhwzBmfwBean> datas = new Datas<StjjMhwzBmfwBean>();
		if (el == null) {
			return null;
		}
		el.forEach(e->{
			StjjMhwzBmfwBean stb = new StjjMhwzBmfwBean();
			stb.setId(Tools.createUUID());
			String title = e.select("h1 a").text();
			stb.setSxbt(title);
			String text = e.text();
			stb.setSxlx(text.substring(text.indexOf("事项类型：")+5, text.indexOf("事项编号：")));
			stb.setSxbm(text.substring(text.indexOf("事项编号：")+5, text.indexOf("办理地点：")));
			stb.setBldd(text.substring(text.indexOf("办理地点：")+5, text.indexOf("服务部门")));
			stb.setFwbm(text.substring(text.indexOf("服务部门：")+5, text.length()));
			datas.getDatas().add(stb);
		});
		return datas;
	}

	@Override
	public Class<StjjMhwzBmfwBean> getTClass() {
		return StjjMhwzBmfwBean.class;
	}
	
	@Override
	public void generateMap(Map<String, Object> map) {
		//作查询条件组装
		
	}
	
	@Override
	public Datas<StjjMhwzBmfwBean> dataAnalysisByJson(String jsonStr) {
		/**
		 * 做json特殊处理
		 */
		return null;
	}
	
	
	@Override
	public Type getSourceType() {
		return Type.HTML;
	}

}
